New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(prometheus) prevent error to use $__interval_ms in query #12533
Conversation
Can you rebase this on latest master? |
This function could use a comment and a test. Currently I have no idea why it's there and what input/output is typical. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @mtanda . A test for this and maybe a comment what this function does. Should this function not always return a string?
Sorry, I'm not sure what I should do. There are tests for I think |
@mtanda we would like to use opportunities where an error was encountered to extend our unit tests. |
I understand what you need. I add a test case for failure pattern. |
@@ -103,6 +103,10 @@ export class PrometheusDatasource { | |||
interpolateQueryExpr(value, variable, defaultFormatFn) { | |||
// if no multi or include all do not regexEscape | |||
if (!variable.multi && !variable.includeAll) { | |||
if (typeof value === 'number') { | |||
// $__interval_ms type is number, convert to string here | |||
value = value.toString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure this is the correct place to solve this, maybe the root issue should be fixed instead? wonder if allowing $__interval_ms to have number value is not correct but it should be turned into string when it is save in scopedVars (in metrics_ctrl & prometheus datasource.ts)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I little hesitate to break the current behavior, but I agree the data type should be string.
* grafana/master: (29 commits) skip backend request if extended statistics is invalid. (grafana#12495) Refactor team pages to react & design change (grafana#12574) (prometheus) prevent error to use $__interval_ms in query (grafana#12533) fix: folder picker did not notify parent that the initial folder had been changed, fixes grafana#12543 (grafana#12554) Add support for skipping variable value in URL, fixes grafana#12174 (grafana#12541) Don't build-all for PRs fix: requests/sec instead of requets (grafana#12557) Add folder name to dashboard title (grafana#12545) Fix css loading in plugins (grafana#12573) Add new sequential color scales move go vet out of scripts and fixing warning (grafana#12552) Cleanup and remove some jest.fn() Remove irrelevant tests and templateSrv stub Update CHANGELOG.md fix diff and percent_diff (grafana#12515) Update lodash/moment version (grafana#12532) Add mock to test files Create new instance in beforeEach Remove comments Karma to Jest: Cloudwatch datasource ...
* grafana/master: (30 commits) skip backend request if extended statistics is invalid. (grafana#12495) Refactor team pages to react & design change (grafana#12574) (prometheus) prevent error to use $__interval_ms in query (grafana#12533) fix: folder picker did not notify parent that the initial folder had been changed, fixes grafana#12543 (grafana#12554) Add support for skipping variable value in URL, fixes grafana#12174 (grafana#12541) Don't build-all for PRs fix: requests/sec instead of requets (grafana#12557) Add folder name to dashboard title (grafana#12545) Fix css loading in plugins (grafana#12573) Add new sequential color scales move go vet out of scripts and fixing warning (grafana#12552) Cleanup and remove some jest.fn() Remove irrelevant tests and templateSrv stub Update CHANGELOG.md fix diff and percent_diff (grafana#12515) Update lodash/moment version (grafana#12532) Tabs to spaces in tslint (grafana#12529) Add mock to test files Create new instance in beforeEach Remove comments ...
* grafana/master: (30 commits) skip backend request if extended statistics is invalid. (grafana#12495) Refactor team pages to react & design change (grafana#12574) (prometheus) prevent error to use $__interval_ms in query (grafana#12533) fix: folder picker did not notify parent that the initial folder had been changed, fixes grafana#12543 (grafana#12554) Add support for skipping variable value in URL, fixes grafana#12174 (grafana#12541) Don't build-all for PRs fix: requests/sec instead of requets (grafana#12557) Add folder name to dashboard title (grafana#12545) Fix css loading in plugins (grafana#12573) Add new sequential color scales move go vet out of scripts and fixing warning (grafana#12552) Cleanup and remove some jest.fn() Remove irrelevant tests and templateSrv stub Update CHANGELOG.md fix diff and percent_diff (grafana#12515) Update lodash/moment version (grafana#12532) Tabs to spaces in tslint (grafana#12529) Add mock to test files Create new instance in beforeEach Remove comments ...
* prevent error to use $__interval_ms in query * add test * prevent error to use $__interval_ms in query (cherry picked from commit 18a8290)
$__interval_ms
type is integer. It cause error.